/*  J
**  Date 2007-05-29 21:41:04 
**  File io.c  v 1.0
**  Author Mucker
**  See Copyright Notice in J.h
**  
*/

#include "J.h"

#include "io.h"

int  io_fill(JIO *io)
{
	size_t size;
	const char *buff;

	buff = io->reader(io->load, &size);

	if( buff == NULL || size == 0) return EOF;

	io->pos = buff;
	io->unused = size-1;

	return (int)io->pos++;
}

void io_init(JIO *io, J_reader reader, void *load)
{
	io->reader = reader;
	io->load = load;
}

void io_prefill(JIO *io)
{
	io_fill(io);

	io->unused ++;
	io->pos--;
}